from datetime import datetime
from sqlalchemy import Column, Integer, String, DateTime, PrimaryKeyConstraint, Index

from config.database import Base


class KylinFutureAccount(Base):
    """
    期货账户表
    """

    __tablename__ = 'kylin_future_account'
    __table_args__ = (
        PrimaryKeyConstraint('id'),
        Index('idx_future_account_name', 'account_name'),
        {'comment': '期货账户'}
    )
    
    id = Column(Integer, primary_key=True, autoincrement=True, comment='账户id')
    account_code = Column(String(10), nullable=False, comment='账户代码')
    account_name = Column(String(50), nullable=False, comment='账户名称')
    futures_company = Column(String(50), nullable=False, comment='期货公司')
    settlement_account = Column(String(20), nullable=False, comment='结算单账号')
    settlement_password = Column(String(50), nullable=False, comment='结算单密码')
    trade_username = Column(String(20), nullable=False, comment='交易用户名')
    trade_password = Column(String(50), nullable=False, comment='交易密码')
    broker_code = Column(String(20), nullable=False, comment='经纪商代码')
    trade_server = Column(String(100), nullable=False, comment='交易服务器')
    market_server = Column(String(100), nullable=False, comment='行情服务器')
    product_name = Column(String(50), nullable=False, comment='产品名称')
    auth_code = Column(String(50), nullable=False, comment='授权编码')
    product_info = Column(String(50), nullable=False, comment='产品信息')
    create_time = Column(DateTime, default=datetime.now, comment='创建时间')
    update_time = Column(DateTime, default=datetime.now, onupdate=datetime.now, comment='更新时间')